home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2005 July / Macworld CD 17.05.iso / Data / Main.dxr / 00082_listObj.ls < prev    next >
Encoding:
Text File  |  2000-02-28  |  3.9 KB  |  97 lines

  1. property theText, textFont, bgColor, textColor, textSize, textStyle, hiliteColor, hiliteStyle, selectColor, selectStyle, selectScript, selectSound, selectedLine, hilitedLine
  2.  
  3. on new me
  4.   return me
  5. end
  6.  
  7. on getPropertyDescriptionList
  8.   description = [:]
  9.   addProp(description, #textFont, [#default: "Geneva", #format: #string, #comment: "Font of the text:"])
  10.   addProp(description, #bgColor, [#default: 0, #format: #integer, #comment: "ID for the background color of text:"])
  11.   addProp(description, #textColor, [#default: 256, #format: #integer, #comment: "ID for color of the text:"])
  12.   addProp(description, #textSize, [#default: 12, #format: #integer, #comment: "Font size of the text:"])
  13.   addProp(description, #textStyle, [#default: "plain", #format: #string, #comment: "Style of the text:"])
  14.   addProp(description, #hiliteColor, [#default: 5, #format: #integer, #comment: "ID for color of hilited text:"])
  15.   addProp(description, #hiliteStyle, [#default: "plain", #format: #string, #comment: "Style of the hilited text:"])
  16.   addProp(description, #selectColor, [#default: 25, #format: #integer, #comment: "ID for color of selected text:"])
  17.   addProp(description, #selectStyle, [#default: "bold", #format: #string, #comment: "Style of the selected text:"])
  18.   addProp(description, #selectScript, [#default: "none", #format: #string, #comment: "Script when making a selection:"])
  19.   addProp(description, #selectSound, [#default: "none", #format: #string, #comment: "Sound played when making a selection:"])
  20.   return description
  21. end
  22.  
  23. on getBehaviorDescription
  24.   return "Simple selectable list with normal, hilited, and select text colors and styles, and click-sound."
  25. end
  26.  
  27. on beginSprite me
  28.   puppetSprite(me.spriteNum, 1)
  29.   me.selectedLine = 1
  30.   me.hilitedLine = 0
  31.   X = me.spriteNum
  32.   Y = the memberNum of sprite X
  33.   z = member(Y).backcolor
  34.   member(the memberNum of sprite me.spriteNum).backcolor = me.bgColor
  35.   set the foreColor of member the memberNum of sprite the spriteNum of me to me.textColor
  36.   set the textFont of member the memberNum of sprite the spriteNum of me to me.textFont
  37.   set the textStyle of member the memberNum of sprite the spriteNum of me to me.textStyle
  38.   set the textSize of member the memberNum of sprite the spriteNum of me to me.textSize
  39.   mSelect(me)
  40. end
  41.  
  42. on endSprite me
  43.   puppetSprite(me.spriteNum, 0)
  44. end
  45.  
  46. on mouseWithin me
  47.   if (me.hilitedLine <> the mouseLine) and (the mouseLine <> -1) and not SameStyles(me) then
  48.     mClearField(me)
  49.     mSelect(me)
  50.     if the mouseLine <> me.selectedLine then
  51.       set the textStyle of line the mouseLine of member the memberNum of sprite the spriteNum of me to me.hiliteStyle
  52.       set the foreColor of line the mouseLine of member the memberNum of sprite the spriteNum of me to me.hiliteColor
  53.     end if
  54.   end if
  55.   me.hilitedLine = the mouseLine
  56. end
  57.  
  58. on mouseLeave me
  59.   mClearField(me)
  60.   mSelect(me)
  61. end
  62.  
  63. on mouseUp me
  64.   me.selectedLine = the mouseLine
  65.   mClearField(me)
  66.   mSelect(me)
  67.   if me.selectSound <> "none" then
  68.     puppetSound(me.selectSound)
  69.   end if
  70.   if me.selectScript <> "none" then
  71.     do(me.selectScript)
  72.   end if
  73. end
  74.  
  75. on mSelect me
  76.   set the foreColor of line the selectedLine of me of member the memberNum of sprite the spriteNum of me to me.selectColor
  77.   set the textStyle of line the selectedLine of me of member the memberNum of sprite the spriteNum of me to me.selectStyle
  78. end
  79.  
  80. on mHilite me
  81.   set the foreColor of line the hilitedLine of me of member the memberNum of sprite the spriteNum of me to me.hiliteColor
  82.   set the textStyle of line the hilitedLine of me of member the memberNum of sprite the spriteNum of me to me.hiliteStyle
  83. end
  84.  
  85. on mClearField me
  86.   set the textStyle of member the memberNum of sprite the spriteNum of me to me.textStyle
  87.   set the foreColor of member the memberNum of sprite the spriteNum of me to me.textColor
  88. end
  89.  
  90. on SameStyles me
  91.   if (me.textColor = me.hiliteColor) and (me.textStyle = me.hiliteStyle) then
  92.     return 1
  93.   else
  94.     return 0
  95.   end if
  96. end
  97.